package com.shunda.ysdgj.manager.config;

import com.shunda.ysdgj.manager.properties.MinioProperties;
import io.minio.MinioClient;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@RequiredArgsConstructor
public class MinioConfig {

    private final MinioProperties minioProperties;

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(String.format("http://%s:%s", minioProperties.getHost(), minioProperties.getPort()))
                .credentials(minioProperties.getAccessKey(), minioProperties.getAccessSecret())
                .build();
    }

}
